﻿/***********************************************************************
 * <copyright file="ValidateIPAddress.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   LinhMC
 * Email:    linhmc@buca.vn
 * Website:
 * Create Date: Thursday, October 17, 2013
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/

namespace BusinessObjects.BusinessRules
{
    /// <summary>
    ///     IP Address validation rule.
    /// </summary>
    public class ValidateIpAddress : ValidateRegex
    {
        // Match IP Address
        /// <summary>
        ///     Initializes a new instance of the <see cref="ValidateIpAddress" /> class.
        /// </summary>
        /// <param name="propertyName">The property name to which rule applies.</param>
        public ValidateIpAddress(string propertyName) :
            base(propertyName, @"^([0-2]?[0-5]?[0-5]\.){3}[0-2]?[0-5]?[0-5]$")
        {
            ErrorMessage = propertyName + " is not a valid IP Address";
        }

        /// <summary>
        ///     Initializes a new instance of the <see cref="ValidateIpAddress" /> class.
        /// </summary>
        /// <param name="propertyName">The property name to which rule applies.</param>
        /// <param name="errorMessage">The error message.</param>
        public ValidateIpAddress(string propertyName, string errorMessage) :
            this(propertyName)
        {
            ErrorMessage = errorMessage;
        }
    }
}